package com.tn.exam.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.stereotype.Component;

import com.tn.exam.action.base.BaseAction;
import com.tn.exam.constant.ExamConstant;
import com.tn.exam.entity.InfoSysUser;
import com.tn.exam.help.orm.Page;
import com.tn.exam.help.orm.PropertyFilter;
import com.tn.exam.service.UserService;

@Component
@ParentPackage("basePackage")
@Namespace("/appuser")
public class AppUserAction extends BaseAction{
	private UserService sysUserService;
	private Long id;
	private InfoSysUser entity;
	private Page<InfoSysUser> page = new Page<InfoSysUser>(ExamConstant.DAFULT_PAGE_SIZE);//每页5条记录
	private List<Long> checkedRoleIds; //页面中钩选的角色id列表

	@Resource
	public void setSysUserService(UserService sysUserService) {
		this.sysUserService = sysUserService;
	}
	
	@Action(value="list", results={
			@Result(name="list", location="/WEB-INF/content/appuser/list.jsp")
	})
	public String list(){
		
//		List<PropertyFilter> filters = PropertyFilter.buildFromHttpRequest(this.getHttpRequest());
//		//设置默认排序方式
//		if (!page.isOrderBySetted()) {
//			page.setOrderBy("id");
//			page.setOrder(Page.ASC);
//		}
		sysUserService.pageQuery(page);
		page.beforejsp();
		return "list";
	}
	


	public Page<InfoSysUser> getPage() {
		return page;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public InfoSysUser getEntity() {
		return entity;
	}

	public void setEntity(InfoSysUser entity) {
		this.entity = entity;
	}

	public List<Long> getCheckedRoleIds() {
		return checkedRoleIds;
	}

	public void setCheckedRoleIds(List<Long> checkedRoleIds) {
		this.checkedRoleIds = checkedRoleIds;
	}

	public void setPage(Page<InfoSysUser> page) {
		this.page = page;
	}

	public String execute() throws Exception {
		return list();
	}
}
